module_strings.py is arguably the simplest file in the Module System. It contains strings, so blocks of text which can be displayed in various ways. Strings are used all throughout the module system, from module_dialogs.py to module_quests.py; whenever a block of text needs to be displayed on the screen. module_strings.py, however, is a repository for independent strings, which are not bound to any single file. Therefore they can be called by operations from anywhere in the module system. You can see these strings used in various places in the game, as white scrolling messages at the lower left of your screen, or in a tutorial box, or even inserted into a game menu or dialogue sequence.
Much like module_factions.py, this file immediately begins with a Python list: strings = [. The first few tuples are hardwired into the game and should not be edited. Example of a string:
("bandits_eliminated_by_another", "The troublesome bandits have been eliminated by another party."),
or
("s5_s_party", "{s5}'s Party"),
Tuple breakdown:
1) String id. Used for referencing strings in other files.
2) String text.
One notable feature of strings is the ability to put a register value or even another string inside of it. You can do this by adding, for example, {reg0} in the string. This will display the current value of reg(0). {reg10} would display the current value of reg(10), and so on.
For additional strings, you must use the string register instead of a normal register; this is because strings are stored separately from registers. For example, {s2} would display the contents of string register 2 and not the contents of reg(2). You can freely use string register 2 and reg(2) at the same time for different things, they will not overlap or interfere with each other.
String registers have two uses, and two uses only:[1]
For instance, if you have an entry in your module_strings.py file that looks like
("lets_meet_in", "Let's meet in {s10}."),
and a script which contains the lines
(str_store_party_name, 10, "p_zendar"),
(display_message,"str_lets_meet_in"),
then that piece of code will display the message
Let's meet in Zendar.
when it's executed. The {s10} part in the string-entry means "put the current contents of string-register 10 here", while the (str_store_party_name, 10, "p_zendar") part means "store the name of the party p_zendar in string-register 10".
At strings you have to keep in mind some special Syntax rules:
A ^ is a nextline character, allowing you to make line breaks at the text in-game. A \ on the other hand does not add a carrage return in game but is getting used as a Python trick to break the text into multiple lines. By breaking the length of the string it makes the code easier for us humans to read. You can not add any extra spaces on the start of the lines though or it will give a syntax error.[3] A {!} is getting used as a placeholder for an empty string, which otherwise causes problems for the game. It's usually followed by registers or strings, which can be null and won't display properly. It also excludes them from generating a line when you create translation .csv files.[4] It won't show up in-game unless it's a part of a string literal (i.e. party name). Also a _ can get used inside a string which is treated like an empty space (the same is true at the names of items, troops, etc.). E.g. the two strings ("cant_use_inventory_now","Can't access inventory now.") and ("cant_use_inventory_now","Can't_access_inventory_now."), would display the same result in-game.
{reg#} will output the value of that register when used in a string. Using this method the following lines show how the number of a global variable can be used in a string:
(assign, reg1, "$g_your_global_variable"),
(str_store_string, s1, "@The value of the global variable is {reg1}."),
(str_store_string, s0, s1),
As you might already be aware of, a @ begins any quick string which you haven't declared in module_strings.py.
{reg#?str1:str2} tests if reg# is true, and if so, displays str1. Otherwise it displays str2. The value of reg# is here a simply boolean with 1 being true and 0 being false.
Sort out informations given above, currently a mixmax section.
One notable feature of strings is the ability to put a register value or even another string inside of it. You can do this by adding, for example, {reg0} in the string. This will display the current value of reg(0). {reg10} would display the current value of reg(10), and so on.
For additional strings, you must use the string register instead of a normal register; this is because strings are stored separately from registers. For example, {s2} would display the contents of string register 2 - not the contents of reg(2). You can freely use string register 2 and reg(2) at the same time for different things, they will not overlap or interfere with each other.
In dialogue, it is also possible to display parts (or all) of a string's contents differently depending on the gender of the person being addressed. For example, inserting {sir/madam} into a string will cause the word "sir" to be displayed when the addressed person is male, and "madam" if the person is female.
All of these options (except gender-based alternation) will work perfectly in any kind of string field. Gender-based alternations only work in dialogue.
For the purposes of the operation display_message, it is possible to display a string in various colours, by appending a hexadecimal colour code to the operation. For example, (display_message,
Gender at Dialogues
Gender issue dialogues (read carefully and think about improvements at MS), dunde, Modding Q&A
new race gender problem, Somebody, Modding Q&A
gender true false dialog, Somebody, Modding Q&A
gender of new races, Lumos, Modding Q&A
Third option at gender decission not possible and chaining, Lumos, Modding Q&A and Modding Q&A, and Somebody, Modding Q&A
gender dialog, gsanders (credits), Modding Q&A
gender new races, kalarhan, Modding Q&A
gender of skins, kalarhan, Modding Q&A
male female strings, multiple participants, Male races
A quick string is a string that isn't defined in advance in module_strings.py. It can be used anywhere that a string ID would normally be used — normally a string register. A quick string is written exactly like a string literal would be, but it is prefaced with the strudel "@" symbol. Quick strings are therefore sometimes called "@strings" while normal strings are called "str_strings". At compiling quick strings are put into quick_strings.txt but are not getting referenced like strings are. Why would you ever use quick strings over strings? Why doesn't the Module System just put it into strings instead? It is obvious that for momentary message displays quick strings are much more useful, as they can be defined on-the-fly. At the strings in module_strings.py the order (and indexes) are important since some scripts match some other id (for example a scene id) with the string id offset at the same distance from the start. Lists can only be made with strings. Both, strings and quick strings, are getting translated though. Internally, there is no difference between strings and quick strings.[7]
str_ can be reffered to, @ can't. It's literally the only difference. If you are planning "fire and forget" text, use @. If it will participate in other fetures later, save as str.[8]
No string comparision, The_dragon, Modding Q&A
max lenght for strings, cmpxchg8b, Modding Q&A
Hardwired strings, Lav, Modding Q&A
make variable to string, Arch3r, Modding Q&A
store string in global var, kalarhan, Modding Q&A
Convert value to a string, kalarhan, Modding Q&A